import 'dart:io';
import 'package:permission_handler/permission_handler.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:image_picker/image_picker.dart';
import 'package:provider/provider.dart';
import 'package:ytbusiness/config/yt_theme.dart';
import 'package:ytbusiness/page/auto_makers/create_shop/store_picture.dart';
import 'package:ytbusiness/state/user_role.dart';
import 'package:ytbusiness/utils/helper.dart';
import 'package:ytbusiness/utils/screen_adaptation.dart';
import 'package:ytbusiness/widgets/select_time.dart';
import 'package:ytbusiness/widgets/widgets.dart';

class CreateStore extends StatefulWidget {
  @override
  _CreateStoreState createState() => _CreateStoreState();
}

class _CreateStoreState extends State<CreateStore> {
  String _startAndEnd;
  List<int> _serviceCheck = [0]; //选中服务类型
  TextEditingController _storeName = TextEditingController(); //店铺名称
  TextEditingController _storeArea = TextEditingController(); //店铺面积
  TextEditingController _storeArtisan = TextEditingController(); //技工数量
  TextEditingController _principal = TextEditingController(); //负责人
  TextEditingController _principalPhone = TextEditingController(); //负责人电话
  String _address = ""; //店铺地址
  List<File> fileList = []; //店铺图片数组
  File _storeLogo;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: () {
        //输入框失焦
        FocusScope.of(context).requestFocus(FocusNode());
      },
      child: Scaffold(
          backgroundColor: Colors.white,
          appBar: noTitleBar(context),
          body: SingleChildScrollView(
            child: Container(
              margin: EdgeInsets.only(left: setWidth(15), right: setWidth(15)),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.start,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Container(
                    child: Text(
                      "创建店铺名片",
                      style: TextStyle(
                          color: Color(0xff321212),
                          fontSize: setSp(21),
                          fontWeight: FontWeight.w600),
                    ),
                  ),
                  Container(
                    margin: EdgeInsets.only(top: setWidth(3)),
                    child: Text(
                      "向车主介绍一下自己吧",
                      style: TextStyle(
                        color: Color(0xff989898),
                        fontSize: setSp(12),
                      ),
                    ),
                  ),
                  SizedBox(
                    height: setWidth(43),
                  ),
                  //店铺logo
                  Container(
                    decoration: BoxDecoration(
                        border: Border(
                      bottom: BorderSide(
                        color: Color(0xffF0F0F0),
                        width: 0.5,
                      ),
                    )),
                    padding: EdgeInsets.only(
                        top: setWidth(21), bottom: setWidth(21)),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Container(
                          child: Text(
                            "店铺logo",
                            style: TextStyle(
                                color: Color(0xff321212), fontSize: setSp(15)),
                          ),
                        ),
                        GestureDetector(
                          onTap: () {
                            _selectLogo();
                          },
                          child: Container(
                              width: setWidth(44),
                              height: setWidth(44),
                              child: _storeLogo == null
                                  ? Image.asset(
                                      "assets/images/xiulichang.png",
                                      fit: BoxFit.cover,
                                    )
                                  : Image.file(
                                      _storeLogo,
                                      fit: BoxFit.cover,
                                    )),
                        ),
                      ],
                    ),
                  ),
                  Container(
                    padding:
                        EdgeInsets.only(top: setWidth(5), bottom: setWidth(5)),
                    decoration: BoxDecoration(
                        border: Border(
                      bottom: BorderSide(
                        color: Color(0xffF0F0F0),
                        width: 0.5,
                      ),
                    )),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Container(
                          child: Text(
                            "店铺名称",
                            style: TextStyle(
                                color: Color(0xff321212), fontSize: setSp(15)),
                          ),
                        ),
                        SizedBox(
                          width: setWidth(50),
                        ),
                        Expanded(
                            child: Container(
                          child: TextField(
                            controller: _storeName,
                            textAlign: TextAlign.end,
                            maxLines: 1,
                            keyboardType: TextInputType.multiline,
                            autofocus: false,
                            decoration: InputDecoration(
                                border: InputBorder.none,
                                focusedBorder: InputBorder.none,
                                enabledBorder: InputBorder.none,
                                hintText: "请输入店铺名称",
                                hintStyle: TextStyle(
                                    color: Color(0xffC6C9CE),
                                    fontSize: setSp(16))),
                          ),
                        )),
                      ],
                    ),
                  ),
                  //店铺地址
                  Container(
                    decoration: BoxDecoration(
                        border: Border(
                      bottom: BorderSide(
                        color: Color(0xffF0F0F0),
                        width: 0.5,
                      ),
                    )),
                    padding: EdgeInsets.only(
                        top: setWidth(21), bottom: setWidth(21)),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Container(
                          child: Text(
                            "店铺地址",
                            style: TextStyle(
                                color: Color(0xff321212), fontSize: setSp(15)),
                          ),
                        ),
                        SizedBox(
                          width: setWidth(20),
                        ),
                        Expanded(
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.end,
                            children: [
                              Expanded(
                                child: GestureDetector(
                                  onTap: () async {
                                    _getPermission().then((value) {
                                      if (value) {
//                                      Navigator.push(context, MaterialPageRoute(builder: (context){
//                                        return SelectLocationFromMapPage();
//                                      }));

                                      } else {
                                        toast("请打开定位权限");
                                      }
                                    });
                                  },
                                  child: Container(
                                    alignment: Alignment.centerRight,
                                    child: Text(
                                      _address == "" ? "省市区" : _address,
                                      style: TextStyle(
                                          color: Color(0xff989898),
                                          fontSize: setSp(15)),
                                      maxLines: 1,
                                      overflow: TextOverflow.ellipsis,
                                    ),
                                  ),
                                ),
                              ),
                              SizedBox(
                                width: setWidth(5),
                              ),
                              Container(
                                child: Text(
                                  "定位",
                                  style: TextStyle(
                                      color: Color(0xff323232),
                                      fontSize: setSp(15)),
                                ),
                              ),
                              SizedBox(
                                width: setWidth(3),
                              ),
                              Container(
                                width: setWidth(14),
                                height: setWidth(17),
                                child: Image.asset(
                                  "assets/images/black_diangwei.png",
                                  fit: BoxFit.cover,
                                ),
                              ),
                            ],
                          ),
                        ),
                      ],
                    ),
                  ),
                  //经营类目
//                Container(
//                  decoration: BoxDecoration(
//                      border: Border(
//                        bottom: BorderSide(
//                          color: Color(0xffF0F0F0),
//                          width: 0.5,),
//                      )
//                  ),
//                  padding: EdgeInsets.only(top: setWidth(21),bottom: setWidth(21)),
//                  child: Column(
//                    mainAxisAlignment: MainAxisAlignment.start,
//                    crossAxisAlignment: CrossAxisAlignment.start,
//                    children: [
//                      Container(
//                        child: Text("经营类目",style: TextStyle(color: Color(0xff321212),fontSize: setSp(15)),),
//                      ),
//                      Offstage(
//                        offstage:_showServiceList,
//                        child: Container(
//                          margin: EdgeInsets.only(top: setWidth(26)),
//                          child: Wrap(
//                            spacing: setWidth(5),
//                           runSpacing: setWidth(5),
//                           children:_serviceList.asMap().map((index, value){
//                             return MapEntry(index,_serviceItem(index,value));
//                           }).values.toList(),
//                          ),
//                        ),
//                      ),
//                      SizedBox(
//                        height: setWidth(30),
//                      ),
//                      GestureDetector(
//                        behavior: HitTestBehavior.opaque,
//                        onTap: (){
//                          setState(() {
//                            _showServiceList = !_showServiceList;
//                          });
//                        },
//                        child: Row(
//                          mainAxisAlignment: MainAxisAlignment.center,
//                          children: [
//                            Container(
//                              child: Text(_showServiceList?"展开":"折叠",style: TextStyle(color: Color(0xff999999),fontSize: setSp(15)),),
//                            ),
//                            Container(
//                              alignment: Alignment.center,
//                              width: setWidth(30),
//                              height: setWidth(20),
//                              child: SizedBox(width: setWidth(10),
//                                height: setWidth(9.5),
//                                child: Image.asset(_showServiceList?"assets/images/home_done.png":"assets/images/home_up.png",width: setWidth(10),
//                                  height: setWidth(9.5),fit: BoxFit.cover,),
//                              ),
//                            ),
//                          ],
//                        ),
//                      ),
//                    ],
//                  ),
//                ),
                  //实体店照片

                  //实体店照片
                  Container(
                    decoration: BoxDecoration(
                        border: Border(
                      bottom: BorderSide(
                        color: Color(0xffF0F0F0),
                        width: 0.5,
                      ),
                    )),
                    padding: EdgeInsets.only(
                        top: setWidth(26), bottom: setWidth(21)),
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.start,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Container(
                          child: Text(
                            "实体店照片",
                            style: TextStyle(
                                color: Color(0xff321212), fontSize: setSp(15)),
                          ),
                        ),
                        SizedBox(
                          height: setWidth(23),
                        ),
                        StorePicture(
                            getImage: _galleryImage, fileList: fileList),
                      ],
                    ),
                  ),

                  ///修理厂店铺信息
                  Offstage(
                    offstage:
                        Provider.of<UserRole>(context, listen: false).role != 1,
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.start,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        //实体店面积
                        Container(
                          decoration: BoxDecoration(
                              border: Border(
                            bottom: BorderSide(
                              color: Color(0xffF0F0F0),
                              width: 0.5,
                            ),
                          )),
                          padding: EdgeInsets.only(
                              top: setWidth(5), bottom: setWidth(5)),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              Container(
                                child: Text(
                                  "实体店面积",
                                  style: TextStyle(
                                      color: Color(0xff321212),
                                      fontSize: setSp(15)),
                                ),
                              ),
                              SizedBox(
                                width: setWidth(50),
                              ),
                              Expanded(
                                  child: Container(
                                child: TextField(
                                  controller: _storeArea,
                                  textAlign: TextAlign.end,
                                  maxLines: 1,
                                  keyboardType: TextInputType.multiline,
                                  autofocus: false,
                                  inputFormatters: [
                                    WhitelistingTextInputFormatter(
                                        RegExp("[0-9.]")), //只允许输入小数
                                  ],
                                  decoration: InputDecoration(
                                    border: InputBorder.none,
                                    focusedBorder: InputBorder.none,
                                    enabledBorder: InputBorder.none,
                                    hintText: "请输入实体店面积",
                                    hintStyle: TextStyle(
                                        color: Color(0xffC6C9CE),
                                        fontSize: setSp(16)),
                                  ),
                                ),
                              )),
                            ],
                          ),
                        ),
                        //技工数量
                        Container(
                          decoration: BoxDecoration(
                              border: Border(
                            bottom: BorderSide(
                              color: Color(0xffF0F0F0),
                              width: 0.5,
                            ),
                          )),
                          padding: EdgeInsets.only(
                              top: setWidth(5), bottom: setWidth(5)),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              Container(
                                child: Text(
                                  "技工数量",
                                  style: TextStyle(
                                      color: Color(0xff321212),
                                      fontSize: setSp(15)),
                                ),
                              ),
                              SizedBox(
                                width: setWidth(50),
                              ),
                              Expanded(
                                  child: Container(
                                child: TextField(
                                  controller: _storeArtisan,
                                  textAlign: TextAlign.end,
                                  maxLines: 1,
                                  keyboardType: TextInputType.multiline,
                                  autofocus: false,
                                  inputFormatters: [
                                    WhitelistingTextInputFormatter(
                                        RegExp("[0-9]")), //只允许输入数字
                                  ],
                                  decoration: InputDecoration(
                                    border: InputBorder.none,
                                    focusedBorder: InputBorder.none,
                                    enabledBorder: InputBorder.none,
                                    hintText: "请输入技工数量",
                                    hintStyle: TextStyle(
                                        color: Color(0xffC6C9CE),
                                        fontSize: setSp(16)),
                                  ),
                                ),
                              )),
                            ],
                          ),
                        ),
                        //服务时间
                        Container(
                          decoration: BoxDecoration(
                              border: Border(
                            bottom: BorderSide(
                              color: Color(0xffF0F0F0),
                              width: 0.5,
                            ),
                          )),
                          padding: EdgeInsets.only(
                              top: setWidth(20), bottom: setWidth(20)),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              Container(
                                child: Text(
                                  "服务时间",
                                  style: TextStyle(
                                      color: Color(0xff321212),
                                      fontSize: setSp(15)),
                                ),
                              ),
                              GestureDetector(
                                onTap: () {
                                  _selectTime();
                                },
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.end,
                                  children: [
                                    Container(
                                      width: setWidth(15),
                                      height: setWidth(15),
                                      child: Image.asset(
                                        "assets/images/time.png",
                                        fit: BoxFit.cover,
                                      ),
                                    ),
                                    SizedBox(
                                      width: setWidth(3),
                                    ),
                                    Container(
                                      child: Text(
                                        _startAndEnd ?? "请选择服务时间",
                                        style: TextStyle(
                                            color: Color(0xff989898),
                                            fontSize: setSp(15)),
                                      ),
                                    ),
                                    SizedBox(
                                      width: setWidth(3),
                                    ),
                                    Container(
                                      width: setWidth(6),
                                      height: setWidth(11),
                                      child: Image.asset(
                                        "assets/images/right.png",
                                        fit: BoxFit.cover,
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                            ],
                          ),
                        ),
                        //负责人
                        Container(
                          decoration: BoxDecoration(
                              border: Border(
                            bottom: BorderSide(
                              color: Color(0xffF0F0F0),
                              width: 0.5,
                            ),
                          )),
                          padding: EdgeInsets.only(
                              top: setWidth(5), bottom: setWidth(5)),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              Container(
                                child: Text(
                                  "负责人",
                                  style: TextStyle(
                                      color: Color(0xff321212),
                                      fontSize: setSp(15)),
                                ),
                              ),
                              SizedBox(
                                width: setWidth(50),
                              ),
                              Expanded(
                                  child: Container(
                                child: TextField(
                                  controller: _principal,
                                  textAlign: TextAlign.end,
                                  maxLines: 1,
                                  keyboardType: TextInputType.multiline,
                                  autofocus: false,
                                  decoration: InputDecoration(
                                    border: InputBorder.none,
                                    focusedBorder: InputBorder.none,
                                    enabledBorder: InputBorder.none,
                                    hintText: "请输入负责人姓名",
                                    hintStyle: TextStyle(
                                        color: Color(0xffC6C9CE),
                                        fontSize: setSp(16)),
                                  ),
                                ),
                              )),
                            ],
                          ),
                        ),
                        //负责人电话
                        Container(
                          decoration: BoxDecoration(
                              border: Border(
                            bottom: BorderSide(
                              color: Color(0xffF0F0F0),
                              width: 0.5,
                            ),
                          )),
                          padding: EdgeInsets.only(
                              top: setWidth(5), bottom: setWidth(5)),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              Container(
                                child: Text(
                                  "负责人电话",
                                  style: TextStyle(
                                      color: Color(0xff321212),
                                      fontSize: setSp(15)),
                                ),
                              ),
                              SizedBox(
                                width: setWidth(50),
                              ),
                              Expanded(
                                  child: Container(
                                child: TextField(
                                  controller: _principalPhone,
                                  textAlign: TextAlign.end,
                                  maxLines: 1,
                                  keyboardType: TextInputType.multiline,
                                  autofocus: false,
                                  decoration: InputDecoration(
                                    border: InputBorder.none,
                                    focusedBorder: InputBorder.none,
                                    enabledBorder: InputBorder.none,
                                    hintText: "请输入负责人电话",
                                    hintStyle: TextStyle(
                                        color: Color(0xffC6C9CE),
                                        fontSize: setSp(16)),
                                  ),
                                ),
                              )),
                            ],
                          ),
                        ),
                      ],
                    ),
                  ),

                  ///店铺负责人
                  Container(
                    margin: EdgeInsets.only(
                        top: setWidth(38), bottom: setWidth(40)),
                    child: Row(
                      children: [
                        Text(
                          "店铺负责人",
                          style: TextStyle(
                              color: YTTheme.theme,
                              fontSize: setSp(15),
                              fontWeight: FontWeight.w600),
                        )
                      ],
                    ),
                  ),
                  //姓名
                  Container(
                    decoration: BoxDecoration(
                        border: Border(
                      bottom: BorderSide(
                        color: Color(0xffF0F0F0),
                        width: 0.5,
                      ),
                    )),
                    padding:
                        EdgeInsets.only(top: setWidth(5), bottom: setWidth(5)),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Container(
                          child: Text(
                            "姓名",
                            style: TextStyle(
                                color: Color(0xff321212), fontSize: setSp(15)),
                          ),
                        ),
                        SizedBox(
                          width: setWidth(50),
                        ),
                        Expanded(
                            child: Container(
                          child: TextField(
                            textAlign: TextAlign.end,
                            maxLines: 1,
                            keyboardType: TextInputType.multiline,
                            autofocus: false,
                            decoration: InputDecoration(
                              border: InputBorder.none,
                              focusedBorder: InputBorder.none,
                              enabledBorder: InputBorder.none,
                              hintText: "请输入姓名",
                              hintStyle: TextStyle(
                                  color: Color(0xff989898),
                                  fontSize: setSp(16)),
                            ),
                          ),
                        )),
                      ],
                    ),
                  ),
                  //联系电话
                  Container(
                    decoration: BoxDecoration(
                        border: Border(
                      bottom: BorderSide(
                        color: Color(0xffF0F0F0),
                        width: 0.5,
                      ),
                    )),
                    padding:
                        EdgeInsets.only(top: setWidth(5), bottom: setWidth(5)),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Container(
                          child: Text(
                            "联系电话",
                            style: TextStyle(
                                color: Color(0xff321212), fontSize: setSp(15)),
                          ),
                        ),
                        SizedBox(
                          width: setWidth(50),
                        ),
                        Expanded(
                            child: Container(
                          child: TextField(
                            textAlign: TextAlign.end,
                            maxLines: 1,
                            keyboardType: TextInputType.multiline,
                            autofocus: false,
                            decoration: InputDecoration(
                              border: InputBorder.none,
                              focusedBorder: InputBorder.none,
                              enabledBorder: InputBorder.none,
                              hintText: "请输入联系电话",
                              hintStyle: TextStyle(
                                  color: Color(0xff989898),
                                  fontSize: setSp(16)),
                            ),
                          ),
                        )),
                      ],
                    ),
                  ),
                  //地址
                  Container(
                    padding:
                        EdgeInsets.only(top: setWidth(5), bottom: setWidth(5)),
                    decoration: BoxDecoration(
                        border: Border(
                      bottom: BorderSide(
                        color: Color(0xffF0F0F0),
                        width: 0.5,
                      ),
                    )),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Container(
                          child: Text(
                            "地址",
                            style: TextStyle(
                                color: Color(0xff321212), fontSize: setSp(15)),
                          ),
                        ),
                        SizedBox(
                          width: setWidth(50),
                        ),
                        Expanded(
                            child: Container(
                          child: TextField(
                            textAlign: TextAlign.end,
                            maxLines: null,
                            keyboardType: TextInputType.multiline,
                            autofocus: false,
                            decoration: InputDecoration(
                              border: InputBorder.none,
                              focusedBorder: InputBorder.none,
                              enabledBorder: InputBorder.none,
                              hintText: "请输入地址",
                              hintStyle: TextStyle(
                                  color: Color(0xff989898),
                                  fontSize: setSp(16)),
                            ),
                          ),
                        )),
                      ],
                    ),
                  ),

                  ///财务负责人
                  Container(
                    margin: EdgeInsets.only(
                        top: setWidth(38), bottom: setWidth(40)),
                    child: Row(
                      children: [
                        Text(
                          "店铺负责人",
                          style: TextStyle(
                              color: YTTheme.theme,
                              fontSize: setSp(15),
                              fontWeight: FontWeight.w600),
                        )
                      ],
                    ),
                  ),
                  //财务负责人
                  Container(
                    decoration: BoxDecoration(
                        border: Border(
                      bottom: BorderSide(
                        color: Color(0xffF0F0F0),
                        width: 0.5,
                      ),
                    )),
                    padding:
                        EdgeInsets.only(top: setWidth(5), bottom: setWidth(5)),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Container(
                          child: Text(
                            "财务负责人",
                            style: TextStyle(
                                color: Color(0xff321212), fontSize: setSp(15)),
                          ),
                        ),
                        SizedBox(
                          width: setWidth(50),
                        ),
                        Expanded(
                            child: Container(
                          child: TextField(
                            textAlign: TextAlign.end,
                            maxLines: 1,
                            keyboardType: TextInputType.multiline,
                            autofocus: false,
                            decoration: InputDecoration(
                              border: InputBorder.none,
                              focusedBorder: InputBorder.none,
                              enabledBorder: InputBorder.none,
                              hintText: "请输入财务负责人",
                              hintStyle: TextStyle(
                                  color: Color(0xff989898),
                                  fontSize: setSp(16)),
                            ),
                          ),
                        )),
                      ],
                    ),
                  ),
                  //财务电话
                  Container(
                    decoration: BoxDecoration(
                        border: Border(
                      bottom: BorderSide(
                        color: Color(0xffF0F0F0),
                        width: 0.5,
                      ),
                    )),
                    padding:
                        EdgeInsets.only(top: setWidth(5), bottom: setWidth(5)),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Container(
                          child: Text(
                            "财务电话",
                            style: TextStyle(
                                color: Color(0xff321212), fontSize: setSp(15)),
                          ),
                        ),
                        SizedBox(
                          width: setWidth(50),
                        ),
                        Expanded(
                            child: Container(
                          child: TextField(
                            textAlign: TextAlign.end,
                            maxLines: 1,
                            keyboardType: TextInputType.multiline,
                            autofocus: false,
                            decoration: InputDecoration(
                              border: InputBorder.none,
                              focusedBorder: InputBorder.none,
                              enabledBorder: InputBorder.none,
                              hintText: "请输入财务电话",
                              hintStyle: TextStyle(
                                  color: Color(0xff989898),
                                  fontSize: setSp(16)),
                            ),
                          ),
                        )),
                      ],
                    ),
                  ),
                  //地址
                  Container(
                    padding:
                        EdgeInsets.only(top: setWidth(5), bottom: setWidth(5)),
                    decoration: BoxDecoration(
                        border: Border(
                      bottom: BorderSide(
                        color: Color(0xffF0F0F0),
                        width: 0.5,
                      ),
                    )),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Container(
                          child: Text(
                            "地址",
                            style: TextStyle(
                                color: Color(0xff321212), fontSize: setSp(15)),
                          ),
                        ),
                        SizedBox(
                          width: setWidth(50),
                        ),
                        Expanded(
                            child: Container(
                          child: TextField(
                            textAlign: TextAlign.end,
                            maxLines: null,
                            keyboardType: TextInputType.multiline,
                            autofocus: false,
                            decoration: InputDecoration(
                              border: InputBorder.none,
                              focusedBorder: InputBorder.none,
                              enabledBorder: InputBorder.none,
                              hintText: "请输入地址",
                              hintStyle: TextStyle(
                                  color: Color(0xff989898),
                                  fontSize: setSp(16)),
                            ),
                          ),
                        )),
                      ],
                    ),
                  ),

                  SizedBox(
                    height: setWidth(80),
                  ),
                ],
              ),
            ),
          ),
          //提交
          bottomSheet: confirmButton(
              title: "下一步",
              voidCallback: () {
                urlPush(context, "yuntu://wanshanxinxi");
              })),
    );
  }

  //服务类型
  Widget _serviceItem(int index, String value) {
    return GestureDetector(
      onTap: () {
        setState(() {
          if (_serviceCheck.indexOf(index) != -1) {
            _serviceCheck.remove(index);
          } else {
            _serviceCheck.add(index);
          }
        });
      },
      child: Container(
        decoration: BoxDecoration(
            color: _serviceCheck.indexOf(index) != -1
                ? Color(0xffF1F9F5)
                : Color(0xffFFFFFF),
            border: Border.all(color: Color(0xffF0F0F0), width: setWidth(0.5)),
            borderRadius: BorderRadius.circular(2)),
        padding: EdgeInsets.only(
            top: setWidth(8),
            bottom: setWidth(8),
            left: setWidth(17),
            right: setWidth(17)),
        child: Text(
          value,
          style: TextStyle(
              color: _serviceCheck.indexOf(index) != -1
                  ? YTTheme.theme
                  : Color(0xff989898),
              fontSize: setSp(14)),
        ),
      ),
    );
  }

  //选择时间
  _selectTime() {
    return showModalBottomSheet(
      backgroundColor: Color(0xfffafafa),
      context: context,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.only(
          topLeft: Radius.circular(13),
          topRight: Radius.circular(13),
        ),
      ),
      builder: (ctx) {
        return SelectTime(
          onCheckUpdate: (val) {
            setState(() {
              _startAndEnd = val;
            });
          },
        );
      },
    );
  }

  //从相册选择logo
  _selectLogo() async {
    await ImagePicker.pickImage(source: ImageSource.gallery).then((value) {
      if (value != null) {
        setState(() {
          _storeLogo = value;
        });
      }
    });
  }

  //从相册选择图片
  _galleryImage() async {
    await ImagePicker.pickImage(source: ImageSource.gallery).then((value) {
      if (value != null) {
        setState(() {
          fileList.add(value);
        });
      }
    });
  }

  //拍照
  _cameraImage() async {
    await ImagePicker.pickImage(source: ImageSource.camera).then((value) {
      if (value != null) {
        setState(() {
          fileList.add(value);
        });
      }
    });
  }

  Future<bool> _getPermission() async {
    if (await Permission.location.request().isGranted) {
      print("定位授权成功");
      return true;
    } else {
      print("定位授权失败");
      return false;
    }

    //
//    if (permissions[PermissionGroup.location] == PermissionStatus.granted) {
//      return true;
//    } else {
//      ToastUtils.toastLong("需要定位权限!");
//      return false;
//    }
  }

  Future<void> requestPermission() async {
//    Permission permission;
//    final status = await permission.request(Permission.location);
  }
}
